class TouristsController < ApplicationController
  # GET /tourists
  # GET /tourists.xml
  layout 'main'
  def index
    @tourists = Tourist.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @tourists }
    end
  end

  # GET /tourists/1
  # GET /tourists/1.xml
  def show
    @tourist = Tourist.find(params[:id])
    @plan = Plan.find_all_by_user_id(session[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @tourist }
      format.xml  { reder :xml => @plan}
    end
  end

  # GET /tourists/new
  # GET /tourists/new.xml
  def new
    @tourist = Tourist.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @tourist }
    end
  end

  # GET /tourists/1/edit
  def edit
    @tourist = Tourist.find(params[:id])
  end

  # POST /tourists
  # POST /tourists.xml
  def create
    @tourist = Tourist.new(params[:tourist])
    @tourist.img = session[:url]
    respond_to do |format|
      if @tourist.save
        flash[:notice] = 'Tourist was successfully created.'
        format.html { redirect_to(@tourist) }
        format.xml  { render :xml => @tourist, :status => :created, :location => @tourist }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @tourist.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /tourists/1
  # PUT /tourists/1.xml
  def update
    @tourist = Tourist.find(params[:id])

    respond_to do |format|
      if @tourist.update_attributes(params[:tourist])
        flash[:notice] = 'Tourist was successfully updated.'
        format.html { redirect_to(@tourist) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @tourist.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /tourists/1
  # DELETE /tourists/1.xml
  def destroy
    @tourist = Tourist.find(params[:id])
    @tourist.destroy

    respond_to do |format|
      format.html { redirect_to(tourists_url) }
      format.xml  { head :ok }
    end
  end
end
